package com.java.mywxmp.controller;

import java.util.Arrays;
import java.util.Map;

import com.java.mywxmp.utils.PageUtils;
import com.java.mywxmp.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.java.mywxmp.entity.Message;
import com.java.mywxmp.service.MessageService;


/**
 * 消息表
 *
 * @author jl
 * @since 2020-08-25 14:53:40
 */
@RestController
@RequestMapping("wx/message")
public class MessageController {
    @Autowired
    private MessageService messageService;

    /**
     * 带条件分页查询message
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = messageService.queryPage(params);

        return R.ok(page);
    }


    /**
     * 根据主键查询message
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id) {
        Message message = messageService.getById(id);

        return R.ok(message);
    }

    /**
     * 新增message
     */
    @PostMapping("/save")
    public R save(@RequestBody Message message) {
        messageService.save(message);

        return R.ok();
    }

    /**
     * 修改message
     */
    @PutMapping("/update")
    public R update(@RequestBody Message message) {
        messageService.updateById(message);

        return R.ok();
    }

    /**
     * 删除message
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Integer[] ids) {
        messageService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
